package com.fcscs.cservice.client.common.model.restaurants;

import java.util.Collection;
import java.util.Map;

import com.fcscs.core.gwt.common.CoreConstants;
import com.fcscs.core.gwt.common.NonDomainModelData;
import com.fcscs.cservice.client.common.CServiceConstants;
import com.fcscs.cservice.common.CServiceCommonEnums.BookingStatus;
import com.fcscs.cservice.common.CServiceCommonEnums.GuestProfileType;
import com.fcscs.cservice.domain.model.BookingView;
import com.fcscs.share.gwt.common.ShareGWTConstants;
import com.google.gwt.i18n.client.DateTimeFormat;

public class BookingViewModelData extends NonDomainModelData<BookingView>{
	private DateTimeFormat formatDate = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
	public BookingViewModelData(BookingView t) {
		super(t);
	}

	@Override
	protected void populateNames(Collection<String> tempNames) {
		tempNames.add(CServiceConstants.RESTAURANT);
		tempNames.add(CServiceConstants.GUESTNAME);
		tempNames.add(ShareGWTConstants.DATE);
		tempNames.add(CServiceConstants.BOOKINGSTATUS);
		tempNames.add(CServiceConstants.GUESTTYPE);
		tempNames.add(CServiceConstants.GUESTNAME);
	}

	@Override
	protected void populateProps(Map<String, Object> props) {
		props.put(CServiceConstants.GUESTNAME,entity.getLastName()+","+entity.getFirstName());
		props.put(ShareGWTConstants.DATE,formatDate.format(entity.getReservationDate()));
		if (entity.getStatus().equals(BookingStatus.CANCEL.toString())) {
			props.put(CServiceConstants.BOOKINGSTATUS, CoreConstants.CORE_CONSTANTS.cancel());
		}
		if (entity.getStatus().equals(BookingStatus.COMPLETED.toString())) {
			props.put(CServiceConstants.BOOKINGSTATUS, CoreConstants.CORE_CONSTANTS.complete());
		}
		if (entity.getStatus().equals(BookingStatus.CONFIRMED_BOOKING.toString())) {
			props.put(CServiceConstants.BOOKINGSTATUS, CServiceConstants.CSERVICE_CONSTANTS.confirmedBooking());
		}
		if (entity.getStatus().equals(BookingStatus.FAILED.toString())) {
			props.put(CServiceConstants.BOOKINGSTATUS, CServiceConstants.CSERVICE_CONSTANTS.failed());
		}
		if (entity.getStatus().equals(BookingStatus.NO_SHOW.toString())) {
			props.put(CServiceConstants.BOOKINGSTATUS,CoreConstants.CORE_CONSTANTS.noShow());
		}
		if (entity.getStatus().equals(BookingStatus.PENDING.toString())) {
			props.put(CServiceConstants.BOOKINGSTATUS, CServiceConstants.CSERVICE_CONSTANTS.pending());
		}
		if (entity.getStatus().equals(BookingStatus.WAITING_LIST.toString())) {
			props.put(CServiceConstants.BOOKINGSTATUS,CServiceConstants.CSERVICE_CONSTANTS.waitingList());
		}
		props.put(CServiceConstants.RESTAURANT, entity.getRestaurantName());
		props.put(CServiceConstants.PAX, entity.getNationalId());
		props.put(CoreConstants.DESCRIPTION, entity.getNote());
		if (GuestProfileType.IN_HOUSE_GUEST.toString().equals(entity.getGuestType()) ){
			props.put(CServiceConstants.GUESTTYPE, CServiceConstants.CSERVICE_CONSTANTS.inHouseGuest());
		}
		if (GuestProfileType.NON_IN_HOUSE_GUEST.toString().equals(entity.getGuestType())) {
			props.put(CServiceConstants.GUESTTYPE,CServiceConstants.CSERVICE_CONSTANTS.nonInHouseGuest());
		}
		props.put(CServiceConstants.RESTAURANT, entity.getRestaurantName());
	}

	@Override
	protected <X> void setProperty(String property, X value) {
		
	}

}
